package com.huawei.hms.framework.network.restclient.hwhttp.dns.dnresolver;

import com.huawei.hms.framework.common.Logger;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DNManager.ResolveTriggerType;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsUtil;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.dnresolver.DNResolver.DNResolverCallback;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.dnresolver.dnkeeper.DomainResult;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class LocalDNSResolver extends DNResolver {
    private static final String TAG = "LocalDNSResolver";

    LocalDNSResolver(String str, @ResolveTriggerType String str2, DNResolverCallback dNResolverCallback) {
        super(str, 4, str2, dNResolverCallback);
    }

    DomainResult query() {
        Logger.v(TAG, "Resolve to local dns, host: %s, trigger type: %s", this.domain, getTriggerType());
        DomainResult domainResult = new DomainResult();
        try {
            domainResult = DnsUtil.convertAddress(InetAddress.getAllByName(this.domain));
        } catch (UnknownHostException e) {
            Logger.w(TAG, "LocalDNSResolver query failed,UnknownHostException:" + this.domain);
        } catch (Throwable e2) {
            Logger.w(TAG, "LocalDNSResolver query failed, IllegalArgumentException Exception: " + this.domain, e2);
        } catch (Throwable e22) {
            Logger.w(TAG, "LocalDNSResolver query failed, NullPointerException Exception: " + this.domain, e22);
        }
        return domainResult;
    }
}
